﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using SD.Database;

namespace smallDeimos.Game.Alliance
{
    public partial class Main : System.Web.UI.Page
    {
        int UserId;
        protected void Page_Load(object sender, EventArgs e)
        {

            if (Request.Cookies["sd_id"] != null)
            {
                HttpCookie cookie2 = Request.Cookies["sd_id"];
                UserId = int.Parse(cookie2.Value);
            }
            else
            {
                Session["Error"] = "Cookie sd_id doesn't exists";
                Response.Redirect("~/Error.aspx");
                return;
            }
            if (UserFunctions.PlayerHasSpecialBulding(UserId, SD.Database.SpecialBuldings.AllianceCC) == false)
            {
                Label1.Text = "You don't have alliance command center. All options are disabled.";
                LinkButton1.Enabled = false;
                LinkButton2.Enabled = false;
                Panel1.Visible = false;
                return;
            }
            else
            {
                int t = UserFunctions.GetPlayerAlliance(UserId);
                if (t >= 0)
                {
                    Label1.Text = "You are member of alliance: " + AllianceFunctions.GetAllianceName(t);
                    LinkButton1.Visible = false;
                    LinkButton2.Visible = false;
                }
                else
                {
                    Label1.Text = "You may join or create alliance.";
                    Panel1.Visible = false;
                }
            }
        }
    }
}
